package com.isunland.managesystem.adapter;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.rProductsListMain;
import com.isunland.managesystem.utils.MyStringUtil;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/5 15:01
 */

public class CropInfoAdapter extends SimpleButterKnifeAdapterAdapter<rProductsListMain>
    implements View.OnClickListener {

  private Callback mCallback;

  public interface Callback {
    void click(View v, rProductsListMain item);
  }

  public CropInfoAdapter(BaseVolleyActivity context, ArrayList<rProductsListMain> objects,
      Callback callback) {
    super(context, objects);
    this.mCallback = callback;
  }

  public CropInfoAdapter(BaseVolleyActivity context, ArrayList<rProductsListMain> objects) {
    super(context, objects);
  }

  @Override
  protected void customizeView(TextView tvNameSearchPerson, TextView tvDepartmentSearchPerson,
      TextView tvThree, TextView tvFour, TextView tvFive, TextView tvSix, Button btn) {
    super.customizeView(tvNameSearchPerson, tvDepartmentSearchPerson, tvThree, tvFour, tvFive,
        tvSix, btn);
    tvThree.setVisibility(View.VISIBLE);
    btn.setVisibility(View.VISIBLE);
    btn.setOnClickListener(this);
  }

  @Override protected void setText1(TextView tvOne, rProductsListMain item) {
    String productName = context.getString(R.string.productName);
    String colon = context.getString(R.string.colon);
    tvOne.setText(MyStringUtil.connect(productName, colon, item.getProductName()));
  }

  @Override protected void setText2(TextView tvTwo, rProductsListMain item) {
    String mType = context.getString(R.string.mtype);
    String colon = context.getString(R.string.colon);
    tvTwo.setText(MyStringUtil.connect(mType, colon, item.getMtype()));
  }

  @Override protected void setText3(TextView tvThree, rProductsListMain item) {
    String materialKindCom = context.getString(R.string.materialKindCom);
    String colon = context.getString(R.string.colon);
    tvThree.setText(MyStringUtil.connect(materialKindCom, colon, item.getMaterialKindCom()));
  }

  @Override public boolean isEmpty() {
    return false;
  }

  @Override public void onClick(View view) {
    if (view == null || view.getTag() == null) return;
    rProductsListMain item = (rProductsListMain) view.getTag();
    mCallback.click(view, item);
  }
}
